package org.mock.sample.cars;

public class Car {

	private final GearBox gearBox;

	private final ClutchPedal clutchPedal;

	private final GasPedal gasPedal;

	public Car(GearBox gearBox, ClutchPedal clutchPedal, GasPedal gasPedal) {

		if (gearBox == null)
			throw new IllegalArgumentException("gearbox");

		if (clutchPedal == null)
			throw new IllegalArgumentException("clutch pedal");

		if (gasPedal == null)
			throw new IllegalArgumentException("gas pedal");

		this.gearBox = gearBox;

		this.clutchPedal = clutchPedal;

		this.gasPedal = gasPedal;

	}

	
	public void shiftGearUp() {

		if (clutchPedal.getState() == PedalState.RELEASED)
			throw new GearBoxException();

		gearBox.changeUp();

	}

	public void shiftGearDown()  {

		if (clutchPedal.getState() == PedalState.RELEASED)
			throw new GearBoxException();

		gearBox.changeDown();

	}

	public void pressClutch() {

		clutchPedal.press();

	}

	public void releaseClutch() {

		clutchPedal.release();

	}

	public void pressGas() {

		gasPedal.press();

	}

	public void releaseGas() {

		gasPedal.release();

	}


	public GearBox getGearBox() {
		return gearBox;
	}
	
	

}
